import requests
import pymysql # mysql
import re  # 正则表达式

#from  bs4  import BeautifulSoup # beaufulSoup4
#headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36'}
#res = requests.get('http://tangshan.ganji.com/zpshichangyingxiao/',headers=headers)
try:
   # soup = BeautifulSoup(res.text,'html.parser',from_encoding='utf-8')
    #temp= soup.find_all('div','intro_item_content')# 查找 div 标签 class='item'
    #temp = soup.find_all('dl', 'list-noimg job-list clearfix new-dl')
   # for item in  temp:
   #   print(item)
    conn = pymysql.connect(host='localhost',user='root',passwd='qjialiu',db='exercise',port=3306,charset='utf8')
    cursor=conn.cursor()
    cursor.execute("insert into students(id,name,sex,grade)values(%s,%s,%s,%s)",(1,'张三','女',26))


    conn.commit()


   # print(temp[0])
except ConnectionError:
    print('拒绝链接')

## ConnnectionError  连接错误
## HTTPError 404
## Request Time out
## TooManyRedirects  超过了设定的最大重定向次数
# print(res.text)

#print(res.text)
#//requests.post()
# 请求头和 消息体 /


